# ***meta charset="UTF-8"***
# @Time: 2021/2/2 14:02
# @Author: 邢光强
# @Email： 1062584918@qq.com
# @File： base_page.py
# @Project: crm_project

from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from pages.base_page import BasePage

class AddUserPage(BasePage):
    username_locator = (By.XPATH,"/html/body/div[5]/div[2]/div/div[2]/div[2]/form/table/tbody/tr[1]/td[2]/input")
    password_locator = (By.XPATH,"/html/body/div[5]/div[2]/div/div[2]/div[2]/form/table/tbody/tr[2]/td[2]/input")
    category_locator = (By.XPATH,"/html/body/div[5]/div[2]/div/div[2]/div[2]/form/table/tbody/tr[3]/td[2]/select")
    department_locator = (By.XPATH,"/html/body/div[5]/div[2]/div/div[2]/div[2]/form/table/tbody/tr[4]/td[2]/select")
    role_locator = (By.XPATH,"/html/body/div[5]/div[2]/div/div[2]/div[2]/form/table/tbody/tr[5]/td[2]/select")
    submit_locator = (By.XPATH,"/html/body/div[5]/div[2]/div/div[2]/div[2]/form/table/tbody/tr[6]/td[2]/input[1]")

    yxyq_locator = (By.LINK_TEXT,"邮箱邀请")
    yx_username_locator = (By.XPATH,"/html/body/div[5]/div[2]/div/div[2]/div[1]/form/table/tbody/tr[1]/td[2]/input")
    email_locator = (By.NAME,"email")
    yx_category_locator = (By.XPATH,"/html/body/div[5]/div[2]/div/div[2]/div[1]/form/table/tbody/tr[3]/td[2]/select")
    yx_department_locator = (By.XPATH,"/html/body/div[5]/div[2]/div/div[2]/div[1]/form/table/tbody/tr[4]/td[2]/select")
    yx_role_locator = (By.XPATH,"/html/body/div[5]/div[2]/div/div[2]/div[1]/form/table/tbody/tr[5]/td[2]/select")
    yx_submit_locator = (By.XPATH,"/html/body/div[5]/div[2]/div/div[2]/div[1]/form/table/tbody/tr[6]/td[2]/input[1]")



    def input_username(self,username):
        self.find_element(self.username_locator).send_keys(username)

    def input_password(self,password):
        self.find_element(self.password_locator).send_keys(password)

    def category_select(self):
        category_element = self.find_element(self.category_locator)
        return Select(category_element)

    def department_select(self):
        department_element = self.find_element(self.department_locator)
        return Select(department_element)

    def role_select(self):
        role_element = self.find_element(self.role_locator)
        return Select(role_element)

    def submit(self):
        self.find_element(self.submit_locator).click()

    def click_yxyq(self):
        self.find_element(self.yxyq_locator).click()

    def input_yx_username(self,yx_username):
        self.find_element(self.yx_username_locator).send_keys(yx_username)

    def input_email(self,email):
        self.find_element(self.email_locator).send_keys(email)

    def yx_category_select(self):
        yx_category_element=self.find_element(self.yx_category_locator)
        return Select(yx_category_element)

    def yx_department_select(self):
        yx_department_select = self.find_element(self.yx_department_locator)
        return Select(yx_department_select)

    def yx_role_select(self):
        yx_role_select = self.find_element(self.yx_role_locator)
        return Select(yx_role_select)

    def yx_submit(self):
        self.find_element(self.yx_submit_locator).click()


